/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Exercicio3;

/**
 *
 * @author Pedro-Note
 */
public class testeRecursivo {

   testeRecursivo(){

    }
public static double quad(double left,double right, double fleft, double fright,double lrarea) {
    double mid = (left + right) / 2;
    double fmid = Math.floor(mid);
    double larea = (fleft + fmid) * (mid - left) / 2;
    double rarea = (fmid + fright) * (right - mid) / 2;
    if (Math.abs((larea + rarea) - lrarea) > 0.00000000001) {
        larea = quad(left, mid, fleft, fmid, larea);
        rarea = quad(mid, right, fmid, fright, rarea);
    }
    return (larea + rarea);
}
    public static void main(String[] args)
    {
        System.out.println(testeRecursivo.quad(10, 20, 30, 40, 50));
    }
}
